package com.bw.day03.util

import android.content.Context
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bw.day03.R

object GlideUtlis {
    //图片工具类
    fun loadNormal(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .error(R.mipmap.ic_launcher)
            .placeholder(R.mipmap.ic_launcher)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .skipMemoryCache(false)
            .into(imageView)
    }
    fun loadCircle(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .error(R.mipmap.ic_launcher)
            .placeholder(R.mipmap.ic_launcher)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .skipMemoryCache(false)
            .circleCrop()
            .into(imageView)
    }
    fun loadCorner(context: Context,url:String,imageView: ImageView,radius:Int){
        Glide.with(context)
            .load(url)
            .error(R.mipmap.ic_launcher)
            .placeholder(R.mipmap.ic_launcher)
            .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
            .skipMemoryCache(false)
            .transform(CenterCrop(),RoundedCorners(radius))
            .into(imageView)
    }
}